import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import './plugins/iview.js'
import axios from 'axios'
import VueAxios from 'vue-axios'
import global from './views/global.vue'//引用文件
Vue.prototype.GLOBAL = global//挂载到Vue实例上面
Vue.use(VueAxios, axios);
Vue.config.productionTip = false

//axios  拦截卫士 全局添加头信息
axios.interceptors.request.use(function (config) {
  if(store.state.token){
    config.headers.Authorization = `Bearer ${store.state.token}`;
  }
  return config;
}, function (error) {
  // Do something with request error
  return Promise.reject(error);
});
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
